<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/xml" prefix="x"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link href="css/main.css" rel="stylesheet" type="text/css">
<title>Recipes</title>
</head>
<body>
	<div class="container">
		<div class="header">
			<img class="header-image" src="img/header-image.png" alt="Cherry"
				name="header_image" id="header_image" />
		</div>
		<!-- end .header -->

		<div class="main-navigation">
			<c:import url="WEB-INF/xml/diet.xml" var="xmlDietDoc" />
			<c:import url="style-sheet/diet.xsl" var="xslDietDoc" />
			<x:transform xml="${xmlDietDoc}" xslt="${xslDietDoc}" />

			<c:import url="WEB-INF/xml/recipe.xml" var="xmlRecipeDoc" />
			<c:import url="style-sheet/recipe.xsl" var="xslRecipeDoc" />
			<x:transform xml="${xmlRecipeDoc}" xslt="${xslRecipeDoc}" />
		</div>
		
		<div class="menu-category"><h3>${requestScope.RECIPEDTO.name} RECIPES</h3></div>
		<a href="#" onclick="downloadRecipe(${requestScope.RECIPEDTO.id})">Download Recipes</a>
		<div class="menu-container">
			<c:forEach var="dish" items="${requestScope.DISHLIST}">
				<form action="/XMLProject/DishClientServlet" method="POST">
					<input type="hidden" name="name" value="${dish.name}"/>
					<input type="hidden" name="calo" value="${dish.calo}"/>
					<input type="hidden" name="cooking" value="${dish.cooking}"/>
					<input type="hidden" name="description" value="${dish.description}"/>
					<input type="hidden" name="imgPath" value="${dish.imgPath}"/>
					<div class="dish-top">
						<a href="#" onclick="go_to_dish(this)"><img src="${dish.imgPath}" alt="${dish.name}"/></a>
            			<h5><a href="#">${dish.name}</a></h5>
					</div>
				</form>
			</c:forEach>
		</div>
		
		<div class="footer">
  			<img src="img/fptuniversity.png"/>
    		<span style="position:absolute">FPT University</span>
  		</div>
	</div>
</body>
<script type="text/javascript">
	function downloadRecipe(id) {
		alert(id);
		window.open('DownloadServlet?item=recipe&recipeId=' + id, '_blank');
	}
	function go_to_dish(element) {
		var form = element.parentNode.parentNode;
		form.submit();
	}
</script>
</html>